//
//  LoginTypeView.m
//  LK
//
//  Created by ZMac on 2018/4/27.
//  Copyright © 2018年 LKQN. All rights reserved.
//

#import "LoginTypeView.h"


@interface LoginTypeView()

@property (nonatomic, strong) UIView *leftLine;
@property (nonatomic, strong) UIView *rightLine;
@property (nonatomic, strong) UILabel *titleLabel;
//@property (nonatomic, strong) UIButton *wxButton;
//@property (nonatomic, strong) UIButton *qqButton;
@property (nonatomic, strong) UIButton *pcnButton;

@end

@implementation LoginTypeView


- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}

- (void)setup
{
    
    [self addSubview:self.leftLine];
    [self addSubview:self.titleLabel];
    [self addSubview:self.rightLine];
//    [self addSubview:self.wxButton];
//    [self addSubview:self.qqButton];
    [self addSubview:self.pcnButton];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.centerX.equalTo(self);
    }];
    
    [_leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self->_titleLabel);
        make.right.equalTo(self->_titleLabel.mas_left).offset(-10);
        make.width.mas_equalTo(28);
        make.height.mas_equalTo(1);
    }];
    
    [_rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self->_titleLabel);
        make.left.equalTo(self->_titleLabel.mas_right).offset(10);
        make.width.mas_equalTo(28);
        make.height.mas_equalTo(1);
    }];
    
//    [_wxButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerY.equalTo(_qqButton);
//        make.right.equalTo(self->_qqButton.mas_left).offset(-36);
//    }];
    
//    [_qqButton mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.equalTo(self);
//        make.top.equalTo(self->_titleLabel.mas_bottom).offset(23);
//    }];
    
    [_pcnButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.equalTo(self->_titleLabel.mas_bottom).offset(23);
    }];

}

//- (void)qqButtonDidClick:(UIButton *)sender
//{
//    int tag = (int)sender.tag;
//    if (self.delegate != nil && [self.delegate respondsToSelector:@selector(LoginTypeViewDidClick:)])
//    {
//        [self.delegate LoginTypeViewDidClick:tag];
//    }
//}


//- (void)wxButtonDidClick:(UIButton *)sender
//{
//    int tag = (int)sender.tag;
//    if (self.delegate != nil && [self.delegate respondsToSelector:@selector(LoginTypeViewDidClick:)])
//    {
//        [self.delegate LoginTypeViewDidClick:tag];
//    }
//}

- (void)pcnButtonDidClick:(UIButton *)sender
{
    int tag = (int)sender.tag;
    if (self.delegate != nil && [self.delegate respondsToSelector:@selector(LoginTypeViewDidClick:)])
    {
        [self.delegate LoginTypeViewDidClick:tag];
    }
}


- (UILabel *)titleLabel {
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = ColorHex(0xD5D3D2);
        _titleLabel.font = [UIFont systemFontOfSize:12];
        _titleLabel.text = @"其他登录方式";
    }
    return _titleLabel;
}

- (UIView *)leftLine {
    if (_leftLine == nil) {
        _leftLine = [[UIView alloc] init];
        _leftLine.backgroundColor = ColorHex(0xFFFFFF);
    }
    return _leftLine;
}

- (UIView *)rightLine {
    if (_rightLine == nil) {
        _rightLine = [[UIView alloc] init];
        _rightLine.backgroundColor = ColorHex(0xFFFFFF);
    }
    return _rightLine;
}

//- (UIButton *)qqButton {
//    if (_qqButton == nil) {
//        _qqButton = [UIButton buttonWithType:UIButtonTypeCustom];
//        [_qqButton setImage:[UIImage imageNamed:@"QQ"] forState:UIControlStateNormal];
//        [_qqButton addTarget:self action:@selector(qqButtonDidClick:) forControlEvents:UIControlEventTouchUpInside];
//        _qqButton.tag = 2;
//    }
//    return _qqButton;
//}

//- (UIButton *)wxButton {
//    if (_wxButton == nil) {
//        _wxButton = [UIButton buttonWithType:UIButtonTypeCustom];
//        [_wxButton setImage:[UIImage imageNamed:@"wechat"] forState:UIControlStateNormal];
//        [_wxButton addTarget:self action:@selector(wxButtonDidClick:) forControlEvents:UIControlEventTouchUpInside];
//        _wxButton.tag = 1;
//    }
//    return _wxButton;
//}

- (UIButton *)pcnButton {
    if (_pcnButton == nil) {
        _pcnButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_pcnButton setImage:[UIImage imageNamed:@"pcn"] forState:UIControlStateNormal];
        [_pcnButton addTarget:self action:@selector(pcnButtonDidClick:) forControlEvents:UIControlEventTouchUpInside];
        _pcnButton.tag = 1;
    }
    return _pcnButton;
}

@end
